from typing import Union

from fastapi import FastAPI
from model import session
from api import ai

app = FastAPI()


@app.get("/")
def read_root():
    return {"Hello": "World"}


@app.get("/user/{user_id}")
def read_item(user_id: int, q: Union[str, None] = None):
    return {"user_id": user_id, "q": q}

@app.post("/ai/chat")
def ai_chat(model: session.Model):
    res = ai.chat_with_ai(model.prompt)
    return { "res": res}